import service from "../../utils/request.js";
import type {AxiosPromise} from "axios";
import type {TenantInsertVO, TenantPageVO, TenantVO} from "./types.ts";


/**
 * 获取租户信息名字列表
 * @returns {*}
 */
export const getTenantNameList = (): AxiosPromise<TenantVO[]> => {
    return service({
        url: "/tenant/nameList",
        method: 'get',
        data: null
    })
}
/**
 * 分页查询租户信息列表
 * @param payload 分页参数
 */
export const getTenantPage = (payload): AxiosPromise<TenantPageVO[]> => {
    return service({
        url: "/tenant/page",
        method: 'POST',
        data: payload
    })
}
/**
 * 修改租户状态
 */
export const updateTenantStatus = (tenantId: string, status: number): AxiosPromise<Boolean> => {
    return service({
        url: `/tenant/status/${tenantId}/${status}`,
        method: 'PUT',
        data: null
    })
}

/**
 * 删除租户
 * @param tenantId
 */
export const deleteTenant = (tenantId: string): AxiosPromise<Boolean> => {
    return service({
        url: `/tenant/${tenantId}`,
        method: 'DELETE',
        data: null
    })
}

/**
 * 根据租户编号查询租户信息
 */
export const getTenantByTenantId = (tenantId: string): AxiosPromise<TenantPageVO> => {
    return service({
        url: `/tenant/${tenantId}`,
        method: 'GET',
        data: null
    })
}
/**
 * 修改租户信息
 */
export const updateTenant = (tenant: TenantPageVO): AxiosPromise<Boolean> => {
    return service({
        url: `/tenant/update`,
        method: 'PUT',
        data: tenant
    })
}

/**
 * 修改租户信息
 */
export const addNewTenant = (tenant: TenantInsertVO): AxiosPromise<Boolean> => {
    return service({
        url: `/tenant/add`,
        method: 'POST',
        data: tenant
    })
}